import React, { FC, useEffect } from "react";
import { useNavigate, Link } from "react-router-dom";
import { Typography, Button } from "antd";
import { MANAGE_INDEX_PATHNAME } from "../router";
import style from "./home.module.scss";
// import "../_mock/index";
// import axios from "axios";



const { Title, Paragraph } = Typography;
const Home: FC = () => {
  const nav = useNavigate();
  //   function changeRouter() {
  //     // nav('/login')
  //     nav({
  //       pathname: "login",
  //       search: "id=12",
  //     });
  //   }

  useEffect(() => {
    // mockjs 只能用ajsx请求，fetch请求会报错
     fetch("/api/test")
      .then((res) => res.json())
      .then((data) => console.log("fetch data", data));
    // res.data 就是mock数据中return出来的东西
    // axios.get('api/text').then(res => console.log('axios' , res.data))
  }, []);

  return (
    <div className={style.container}>
      <div className={style.info}>
        <Title>问卷调查 ｜ 在线投票</Title>
        <Paragraph>
          已累计创建问卷： 100 ；发布问卷 ： 98 ；收到问卷： 90
        </Paragraph>
        <Paragraph style={{ color: "purple" }}>
          爱意随风起，风止意难平。有缘人请留下你的故事！！
        </Paragraph>
        <Button type="primary" onClick={() => nav(MANAGE_INDEX_PATHNAME)}>
          使用问卷
        </Button>
      </div>
    </div>
  );
};

export default Home;
